<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>09-事件对象</title>
    <style>
        #areaDiv {
            width: 500px;
            height: 100px;
            border: solid 3px #000;
        }

        #showMsg {
            width: 500px;
            height: 50px;
            border: solid 3px #000;
            margin-top: 10px;
        }
    </style>

    <script>
        window.onload = function () {

            /*需求：当鼠标在areaDiv中移动时，在showMsg中来显示鼠标的坐标*/


            var areaDiv = document.getElementById("areaDiv");
            var showMsg = document.getElementById("showMsg");

            //onmousemove事件，在鼠标移动时触发
            areaDiv.onmousemove = function (event) {

                //clientX,clientY获取鼠标的坐标
                var x = event.clientX;
                var y = event.clientY;

                showMsg.innerHTML="x = "+x+", y = "+y;
            }

        }
    </script>
</head>

<body>
    <div id="areaDiv"></div>
    <div id="showMsg"></div>

</body>

</html>